﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.NeighborUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import Display.*;
    import flash.text.*;
    import org.aswing.border.*;
    import Display.aswingui.*;
    import L10n.*;

    public class FriendFTVRewardDialogView extends GenericDialogView {

        protected var m_amount:int;
        protected var m_amountField:JTextField;
        protected var m_friend:Player;
        protected var m_pic:Loader;
        protected var m_picHasLoaded:Boolean = false;
        private var m_friendFrameAP:AssetPane;
        private var m_coins:int;
        private var m_energy:int;
        private var m_xp:int;
        private var m_firstTime:Boolean = false;
        protected var m_acceptTextToken:String;
        protected var m_mainImage:DisplayObject;
        private var m_imagePanel:JPanel;

        public function FriendFTVRewardDialogView(_arg1:Dictionary, _arg2:int=0, _arg3:int=0, _arg4:int=0, _arg5:String="", _arg6:String="", _arg7:int=0, _arg8:Function=null, _arg9:Boolean=false){
            this.m_coins = _arg2;
            this.m_energy = _arg3;
            this.m_xp = _arg4;
            this.m_firstTime = _arg9;
            this.m_acceptTextToken = "Accept";
            super(_arg1, _arg5, _arg6, _arg7, _arg8);
        }
        public function get amount():int{
            return (this.m_amount);
        }
        public function get friend():Player{
            return (this.m_friend);
        }
        override protected function init():void{
            var _local1:String;
            m_acceptTextName = ZLoc.t("Dialogs", this.m_acceptTextToken);
            m_bgAsset = m_assetDict["dialog_bg"];
            this.m_friend = m_assetDict["friend"];
            if (((this.m_friend) && (this.m_friend.snUser))){
                _local1 = this.m_friend.snUser.picture;
                if (_local1){
                    this.m_pic = LoadingManager.load(_local1, this.fillFriendFrame, LoadingManager.PRIORITY_LOW);
                    (this.m_pic as Loader).contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onLoadPicFail, false, 2);
                };
            };
            if (this.m_pic == null){
                this.m_pic = new EmbeddedArt.hud_no_profile_pic();
                this.m_pic.width = 48;
                this.m_pic.height = 48;
            };
            makeBackground();
            makeCenterPanel();
            ASwingHelper.prepare(this);
        }
        override protected function createTitlePanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            title = ASwingHelper.makeTextField(m_titleString, EmbeddedArt.TITLE_FONT, m_titleFontSize, EmbeddedArt.titleColor);
            title.filters = EmbeddedArt.titleFilters;
            var _local2:TextFormat = new TextFormat();
            _local2.size = m_titleSmallCapsFontSize;
            TextFieldUtil.formatSmallCaps(title.getTextField(), _local2);
            _local1.append(title);
            title.getTextField().height = (m_titleFontSize * 1.5);
            ASwingHelper.setEasyBorder(_local1, 4);
            return (_local1);
        }
        override protected function createInteriorHolder():JPanel{
            var _local13:JPanel;
            var _local1:JPanel = new JPanel(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, -18, SoftBoxLayout.TOP));
            var _local2:JPanel = createHeaderPanel();
            ASwingHelper.prepare(_local2);
            textArea = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
            var _local3 = 260;
            var _local4:AssetPane = ASwingHelper.makeMultilineText(this.m_message, _local3, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 16, EmbeddedArt.blueTextColor);
            var _local5:JPanel = ASwingHelper.centerElement(_local4);
            var _local6:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            textArea.appendAll(this.makeFriendPanel(), _local5);
            _local6.append(ASwingHelper.verticalStrut(10));
            _local6.append(textArea);
            _local6.append(ASwingHelper.verticalStrut(5));
            var _local7:DisplayObject = new EmbeddedArt.neighborVisitBlueHighlight();
            var _local8:MarginBackground = new MarginBackground(_local7, new Insets(0, 0, 0, 0));
            var _local9:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            _local9.setBackgroundDecorator(_local8);
            _local9.setPreferredWidth(_local7.width);
            _local9.setMinimumWidth(_local7.width);
            _local9.setMaximumWidth(_local7.width);
            _local9.setPreferredHeight(_local7.height);
            _local9.setMinimumHeight(_local7.height);
            _local9.setMaximumHeight(_local7.height);
            var _local10:JPanel = this.makeIconPanel(EmbeddedArt.neighborVisitLargeXP, this.m_xp, "VRNumXP", (_local7.width / 3));
            _local9.append(_local10);
            _local10 = this.makeIconPanel(EmbeddedArt.neighborVisitLargeCoin, this.m_coins, "VRNumCoins", (_local7.width / 3));
            _local9.append(_local10);
            _local10 = this.makeIconPanel(EmbeddedArt.neighborVisitLargeEnergy, this.m_energy, "VRNumEnergy", (_local7.width / 3));
            _local9.append(_local10);
            _local6.append(_local9);
            this.m_imagePanel = this.makeImagePanel();
            var _local11:JPanel = new JPanel(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, -21, SoftBoxLayout.TOP));
            _local11.append(this.m_imagePanel);
            var _local12:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
            _local12.append(_local11);
            _local12.append(ASwingHelper.horizontalStrut(10));
            _local12.append(_local6);
            _local12.append(ASwingHelper.horizontalStrut(20));
            ASwingHelper.prepare(textArea);
            _local1.setBorder(new EmptyBorder(null, new Insets(0, 0, 0, 0)));
            if (m_type != TYPE_NOBUTTONS){
                _local1.append(_local2);
            };
            _local1.append(ASwingHelper.verticalStrut(30));
            _local1.append(_local12);
            _local1.append(ASwingHelper.verticalStrut(BUTTON_MARGIN));
            if (((!((m_type == TYPE_MODAL))) && (!((m_type == TYPE_NOBUTTONS))))){
                _local13 = createButtonPanel();
                _local1.append(_local13);
            };
            ASwingHelper.prepare(_local1);
            _local2.setPreferredWidth(_local1.getWidth());
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeImagePanel():JPanel{
            var _local2:Insets;
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            if (this.m_firstTime){
                _local2 = new Insets(5, 0, 0, 0);
            } else {
                _local2 = new Insets(5, 8, 0, 0);
            };
            ASwingHelper.setSizedBackground(_local1, m_assetDict["image"], _local2);
            return (_local1);
        }
        private function fillFriendFrame(_arg1:Event):void{
            var _local2:Sprite = new Sprite();
            var _local3:DisplayObject = this.m_pic.content;
            LocaleHelper.localSetting.DisplayObject_adjust(_local3, {
                width:48,
                height:48
            });
            _local2.addChild(_local3);
            this.m_friendFrameAP.setAsset(_local2);
            this.m_picHasLoaded = true;
            ASwingHelper.prepare(this);
        }
        private function onLoadPicFail(_arg1:Event):void{
            if (!this.m_picHasLoaded){
                _arg1.stopPropagation();
                _arg1.stopImmediatePropagation();
                LoadingManager.cancelLoad(this.m_pic);
                this.m_picHasLoaded = true;
            };
        }
        protected function makeIconPanel(_arg1:Class, _arg2:int, _arg3:String, _arg4:Number):JPanel{
            var _local5:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            var _local6:DisplayObject = (new (_arg1)() as DisplayObject);
            var _local7:AssetPane = new AssetPane(_local6);
            var _local8:String = ZLoc.t("Dialogs", _arg3, {number:_arg2});
            var _local9:AssetPane = ASwingHelper.makeMultilineText(_local8, _arg4, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 16, EmbeddedArt.brownTextColor, null, true);
            var _local10:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            _local10.appendAll(ASwingHelper.verticalStrut(3), _local9);
            ASwingHelper.prepare(_local10);
            var _local11:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
            _local11.append(ASwingHelper.horizontalStrut(((_arg4 - _local6.width) / 2)));
            _local11.append(_local7);
            _local5.appendAll(ASwingHelper.verticalStrut(12), _local11, ASwingHelper.verticalStrut(4), _local10);
            _local5.setPreferredWidth(_arg4);
            ASwingHelper.prepare(_local5);
            return (_local5);
        }
        private function makeFriendPanel():JPanel{
            this.m_friendFrameAP = new AssetPane(new Sprite());
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            var _local2:JPanel = ASwingHelper.verticalStrut(2);
            _local1.append(_local2);
            _local1.append(this.m_friendFrameAP);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }

    }
}//package Display.NeighborUI 
